package edu.java.lectures.lec09.exceptions.throwing;

public class ThrowExceptionTest {

    public static void main(String[] args) {
	try {
	    doDivision(1, 0);
	} catch (IllegalArgumentException ae) {
	    System.out.println(ae.getMessage());
	    ae.printStackTrace();
	}
	System.out.println("abc");

	try {
	    doSomething();
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }

    public static void doSomething() throws Exception {
	Exception myException = new Exception(
		"Something horrible has happened.");
	// try {
	if (0 == 0) {
	    throw myException;
	}
	// } catch (Exception e) {
	//	    
	// }
	System.out.println("abc");
    }

    private static boolean doDivision(int a, int b) {
	// throws IllegalArgumentException {
	if (b == 0) {
	    throw new IllegalArgumentException(
		    "Illegal argument: divizor could NOT be zero.");
	}
	a = a / b;
	return true;
    }
}
